function Task() {
    var baseUrl = "/m";

    /**
     * 执行算法
     * @param taskId
     * @param solverMethod
     * @param solverParameters
     * @param callback
     */
    this.execute = function (taskId, solverMethod, solverParameters, callback) {
        
        var conditionSettings = {};
        conditionSettings.solverMethod = solverMethod;
        conditionSettings.solverParameters = JSON.stringify(solverParameters);

        var data = {};
        data.id = taskId;
        data.conditionSettings = JSON.stringify(conditionSettings);
        var ret = 0;
        jQuery.ajax({
            type: "POST",
            url: baseUrl + "/task/execute",
            data: data,
            dataType: "json",
            success: function (res) {
                ret = res
            },
            complete: function () {
                if (callback) {
                    callback(ret);
                }
            }
        });
    }

    /**
     * solverMethod
     * @type {{convention: string, conventionPart: string, elective: string, electiveCoursePlan: string}}
     */
    this.solverMethod = {
        convention: "convention",
        // conventionPart : "convention-part",
        elective: "elective",
        electiveCoursePlan: "elective-course-plan"
    }

    /**
     *
     * @param taskId
     * @param callback
     */
    this.getTask = function (taskId, callback) {
        $.ajax({
            url: baseUrl + "/task/one",
            data: { "id": taskId },
            success: function (ret) {
                var task = JSON.parse(ret);
                callback(task);
            }
        })
    }

    /**
     *
     * @param taskId
     * @param callback
     */
    this.getTaskName = function (taskId, callback) {
        $.ajax({
            url: baseUrl + "/task/name",
            data: { "id": taskId },
            success: function (ret) {
                var name = ret;
                callback(name);
            }
        })
    }


    /**
     *
     * @param name
     * @param period
     * @param copyId
     * @param callback
     */
    this.addTask = function (name, period, copyId, callback) {
        $.ajax({
            type: "POST",
            url: baseUrl + "/task/add",
            data: { "name": name, "period": period, "copyId": copyId },
            success: function (ret) {
                var taskId = ret;
                callback(taskId);
            }
        });
    }
}